import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;

import Framework.*;



public class win_MoviePlayer extends pnl_Ancestor implements ActionListener{

	btn_TopButtons b_TopButtons 	= new btn_TopButtons("My Little Pony");
	
	Timer tmr_HideButtons ; // 5 Seconds
	
	// Setting up bottom menu
	btn_BottomButtons 	b_BottomButtons = new btn_BottomButtons(6);
	btn_Ancestor 			btn_btm_Playlist = new btn_Ancestor("Playlist");
	btn_Ancestor 			btn_btm_Audio = new btn_Ancestor("Audio");
	
	
	// In Window buttons. Text only atm TODO Images on buttons!
	btn_Ancestor btn_Pause = new btn_Ancestor("II");
	btn_Ancestor btn_Play = new btn_Ancestor("|>");
	btn_Ancestor btn_Next = new btn_Ancestor("|>>");
	btn_Ancestor btn_Prev = new btn_Ancestor("<<|");
	btn_Ancestor btn_Stop = new btn_Ancestor("Ohk, not even I can ascii this one.");
	btn_Ancestor btn_Mute = new btn_Ancestor("Mute.");
	btn_Ancestor btn_Transperant = new btn_Ancestor(""); // Transperant button.
	
	boolean ib_VisibleStatus = true;
	public win_MoviePlayer(){
		super(); // Remember to always call super on JPanel_Anc constructors!
		this.setBackgroundImage("img/myLittlePony.jpg");
		btn_Transperant.setBounds(0,0,800,600);
		btn_Transperant.setimg_Background_Down("img/Transperant.png");
		btn_Transperant.setimg_Background_Hover("img/Transperant.png");
		btn_Transperant.setimg_Background_Standard("img/Transperant.png");
		btn_Transperant.addActionListener(this);
		this.add(btn_Transperant);
		// Adding Top buttons
		this.add(b_TopButtons);
		
		// Adding bottom buttons
		b_BottomButtons.add(btn_btm_Playlist, 1);
		b_BottomButtons.add(btn_btm_Audio, 5);
		btn_btm_Playlist.addActionListener(this);
		btn_btm_Audio.addActionListener(this);
		
		// Setting coordinates and size of Buttons.
		btn_Pause.setBounds(50,400,50,50);
		btn_Pause.setVisible(false);
		
		btn_Play.setBounds(50,400,50,50);
		btn_Next.setBounds(110,400,50,50);
		btn_Prev.setBounds(170,400,50,50);
		btn_Stop.setBounds(230,400,50,50);
		btn_Mute.setBounds(280,400,50,50);
		
		// Adding buttons to event handler.
		btn_Play.addActionListener(this);
		btn_Pause.addActionListener(this);
		btn_btm_Playlist.addActionListener(this);
		
		// Adding content
		this.add(btn_Pause);
		this.add(btn_Play);
		this.add(btn_Next);
		this.add(btn_Prev);
		this.add(btn_Stop);
		this.add(btn_Mute);

		this.add(b_BottomButtons);
		tmr_HideButtons = new Timer(500, this);
		tmr_HideButtons.setInitialDelay(5000);
		tmr_HideButtons.start();
		this.validate();
		this.repaint();
	}	
	
	public void showButtons(){
		
	}
	public void setVisibleObjects(boolean ab_Visible){
		b_BottomButtons.setVisible(ab_Visible);
		btn_Play.setVisible(ab_Visible);
		btn_Pause.setVisible(ab_Visible);
		btn_Next.setVisible(ab_Visible);
		btn_Prev.setVisible(ab_Visible);
		btn_Stop.setVisible(ab_Visible);
		btn_Mute.setVisible(ab_Visible);
		b_TopButtons.setVisible(ab_Visible);
		if (ab_Visible){
			tmr_HideButtons.restart();
		
		}
		ib_VisibleStatus = ab_Visible;
		
		btn_Transperant.setVisible(!ab_Visible);
		
		this.validate();
		this.repaint();
		
	}
	public void actionPerformed(ActionEvent e) {
		tmr_HideButtons.restart();
		
		
		if (e.getSource().equals(tmr_HideButtons)){
				setVisibleObjects(false);		
				tmr_HideButtons.stop();
				return;
		}
		
		// ancButton checks go here!
		
		Object actionSource = (btn_Ancestor) e.getSource();
		if (actionSource.equals(btn_Play)){
			btn_Play.setVisible(false);
			btn_Pause.setVisible(true);
		} else if (actionSource.equals(btn_Pause)){
			btn_Play.setVisible(true);
			btn_Pause.setVisible(false);
		} else if (actionSource.equals(btn_btm_Playlist)){
			enterSubMenu(TeamRocket.w_Playlist);
		} else if (actionSource.equals(btn_Transperant)){
			if (ib_VisibleStatus){
				setVisibleObjects(false);
			} else {
				setVisibleObjects(true);
			}
		} else if (actionSource.equals(btn_btm_Audio)){
			this.getRootPane().setContentPane(TeamRocket.w_Media);
		}
		
	}
}
